package stkr;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JWindow;
import javax.swing.event.MouseInputAdapter;

public class StkrWindow extends JWindow {

	/**
	 * 
	 */
	
	private static final long serialVersionUID = -3996167007334122744L;

	private JLabel label;
	public StkrWindow() {
		setAlwaysOnTop(true);
		getContentPane().setLayout(new BorderLayout());
		
		JPanel p = new JPanel();
		p.setLayout(new BorderLayout());
		p.addMouseMotionListener((MouseMotionListener) new DragHandler());
		label = new JLabel("sadfasdf");
		
		p.add(label,BorderLayout.WEST);
		JButton closer = new JButton("x");
		closer.setSize(1, 1);
		closer.addActionListener(new ExitHandler());
		p.add(closer,BorderLayout.EAST);
		

		getContentPane().add(p, BorderLayout.NORTH);
		setSize(1200, 23);
		setVisible(true);
		
	}

public void setLabel(String label){
	this.label.setText(label);
}
	
	private class DragHandler extends MouseInputAdapter {
		public void mouseDragged(MouseEvent event) {
			
			int x = event.getX();
			int y = event.getY();
			int screenX = StkrWindow.this.getX();
			int screenY = StkrWindow.this.getY();
			screenX += x;
			screenY += y;
			StkrWindow.this.setLocation(screenX, screenY);
		}
	}

	private class ExitHandler implements ActionListener {
		public void actionPerformed(ActionEvent event) {
			System.exit(0);
		}
	}

}
